import Vue from 'vue'
import VueRouter from 'vue-router'
import Film from '@/views/Film'
import Cinema from '@/views/Cinema'
import Search from '@/views/Cinema/Search'
import City from '@/views/Cinema/City'
import Center from '@/views/Center'
import Nowplaying from '@/views/Film/Nowplaying'
import Nowlist from '@/views/Film/Nowlist'
import Comingsoon from '@/views/Film/Comingsoon'
import Comelist from '@/views/Film/Comelist'
import ErrorComponent from '@/views/Errorcomponent'
import Log from '@/views/Center/Log'

Vue.use(VueRouter)

const routes = [
  {
    path: '/film',
    component: Film,
    children: [
      {
        path: '/film/nowplaying',
        component: Nowplaying
      },
      {
        path: '/film/comingsoon',
        component: Comingsoon
      },
      {
        path: '/film',
        redirect: '/film/nowplaying' // 重定向
      }
    ]
  },
  {
    path: '/cinema',
    component: Cinema
  },
  {
    path: '/cinema/search',
    component: Search
  },
  {
    path: '/city',
    component: City
  },
  {
    path: '/center',
    component: Center
  },
  {
    path: '/Nowlist/:id', // 具体影片，传递id
    component: Nowlist
  },
  {
    path: '/Comelist/:id', // 具体影片，传递id
    component: Comelist
  },
  {
    path: '/center/log',
    component: Log
  },
  {
    path: '/',
    redirect: '/film/nowplaying' // 重定向
  },
  {
    path: '*',
    component: ErrorComponent // 所有路径都不匹配返回404
  }
]

const router = new VueRouter({
  routes
})

export default router
